import QtQuick 1.0
import QtWebKit 1.0
import com.meego 1.0
import "Forum.js" as ForumUtil
import "CommomUtil.js" as Util

Page {
    id:forumClubPage


    orientationLock : PageOrientation.LockPortrait


    tools:toolbar_container

    property string  current_page_index: "1"  //默认显示第一页

    property string article_id:ForumUtil.getCurrentTopicId()//帖子id

    property string page_num:ForumUtil.getCurrentTopicPageNum()//帖子的页数



    //标题头
    Rectangle{
        id:title_rect
        width: 480
        height: 71
        z: 10
        anchors.top: forumClubPage.top;anchors.left: forumClubPage.left

        BorderImage {
            id: titlebar_back
            source: "../images/commom/titleBack.png"
            width: title_rect.width; height: title_rect.height
            anchors.fill: title_rect
        }

        Text {
            id: title
           // color: "#f7f0f0"
            color: "white"
            text:"第"+forumClubPage.current_page_index+"/"+forumClubPage.page_num+"页"
            horizontalAlignment: Text.AlignHCenter
            font.bold: true; font.pointSize: 16;
            anchors.centerIn: titlebar_back
        }
    }

     Rectangle{
            id:content_rect
            width:parent.width
            height:parent.height - 71
            anchors.top: title_rect.bottom
            color:"#ebeff9"


            FlickWebView {
                id: web_view
                width: parent.width
                height: parent.height
                anchors.fill: parent
                clip: true
                url: ForumUtil.getClubPageUrl(article_id,current_page_index)
                onUrlChanged: {
                   var currentUrl= web_view.url;

                    console.log(currentUrl);
                }
            }
        }


     ToolBarLayout{
         id: toolbar_container
         width: forumClubPage.width; height: 73

         //返回
         ToolIcon {
             id: back_bt
             iconId: "toolbar-back"
             width: toolbar_container.width / 6; height: toolbar_container.height
             anchors.left: parent.left; anchors.bottom: toolbar_container.bottom
             platformStyle: toolBar_style
             onClicked: {Util.back();}
         }

         //上一页
         ToolButton{
             id: prepage_bt
             text: "上一页"
             font { family: "Helvetica"; pointSize: 16; bold: true }
             width: toolbar_container.width * 5 / 18; height: toolbar_container.height
             anchors.left: back_bt.right; anchors.bottom: toolbar_container.bottom
             platformStyle: toolBar_style
             onClicked: {prePage();}
         }



         //下一页
         ToolButton{
             id: nextpage_bt
             text: "下一页"
             font { family: "Helvetica"; pointSize: 16; bold: true }
             width: toolbar_container.width * 5 / 18; height: toolbar_container.height
             anchors.left: prepage_bt.right; anchors.bottom: toolbar_container.bottom
             platformStyle: toolBar_style
             onClicked: {nextPage();}
         }

         ToolButtonStyle{
             id: toolBar_style
             backgroundVisible: false
             pressedBackground: "image://theme/meegotouch-button-navigationbar-button" + __invertedString + "-background-pressed"
         }
     }
     function prePage(){
         if(forumClubPage.current_page_index > 1){
             web_view.currentUrl=ForumUtil.getClubPageUrl(article_id,current_page_index-1)
         }
     }

     function nextPage(){
         if(forumClubPage.current_page_index < forumClubPage.page_num){
             web_view.currentUrl=ForumUtil.getClubPageUrl(article_id,current_page_index+1);
         }
     }
}

